import { BASE_URL } from "@/settings";
import request, { uploadFileReq, downloadFileReq } from "@/utils/request";

export function uploadImg(filePath) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/general/uploadImg`,
    filePath: filePath,
    name: "files"
  });
}

export function uploadFile(filePath) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/general/upload/inline`,
    filePath: filePath,
    name: "files"
  });
}

export function uploadSiteImg(filePath) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/site/uploadImg`,
    filePath: filePath,
    name: "files"
  });
}
export function uploadSiteImgIdCard(filePath, e) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/general/uploadImgAndOCR?valid=true&idCardSide=${e}`,
    filePath: filePath,
    name: "file",
    valid: true
  });
}

export function uploadGeneralBankCard(filePath) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/general/uploadImgAndOCRBankcard`,
    filePath,
    name: "file",
    valid: true
  });
}

export function uploadSiteFile(filePath) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/site/upload/inline`,
    filePath: filePath,
    name: "files"
  });
}

export function uploadFileFormData(filePath,formData) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/site/uploadAndSetName/inline`,
    filePath: filePath,
    formData:{
      fileNames:formData
    },
    name: "files"
  });
}
// filePath: filePath,  ?fileNames=${formData}
    // fileNames:formData,
//     name: 'files'
export function downloadFile(url) {
  console.log("download_url", url);
  return downloadFileReq({
    url: url
  });
}

export function loadAreaReq() {
  return request({
    url: `${BASE_URL}/admin/api/v1/areas/getAllListReduce`,
    method: "get"
  });
}

export function smsSendReq(phone) {
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/hrSendShortMessageByDeviceType`,
    method: 'post',
    data: phone
  })
}

export function smsVerifyReq(data) {
  return request({
    url: `${BASE_URL}/hr/api/v1/hrEmpInfoRelation/hrVerificationCodeLoginWeChatByDevicetypeNoLogic`,
    method: 'post',
    data
  })
}

export function uploadGeneralImgIdCard(filePath, e) {
  return uploadFileReq({
    url: `${BASE_URL}/file/api/v1/general/uploadImgAndOCR?valid=true&idCardSide=${e}`,
    filePath: filePath,
    name: "file",
    valid: true
  });
}
